#include <system.h>


enum xcamera_enums {
	
	XCAMERA_START = 0x90,
	XCAMERA_ACK,
	XCAMERA_SNAP,
};

message_t xcamera_msg;


void XCAMERA_init(void) {
	
}

void XCAMERA_startdone(error_t err) {
	
	if (err != SUCCESS) {
		LEDS4_on(LEDS4_RED);
		return;
	}
	
	LEDS4_off(LEDS4_YELLOW);
	
	uint8_t* data = XPACKET_getData(&xcamera_msg);
	
	data[0] = XCAMERA_ACK;
	data[1] = XCAMERA_START;
	
	if (XPACKET_send(XPACKET_TYPE_CAMERA, &xcamera_msg, 2) == SUCCESS)
		LEDS4_on(LEDS4_GREEN);
}

void XCAMERA_senddone(error_t err) {
	
	LEDS4_off(LEDS4_GREEN);
}

void XCAMERA_getdone(error_t err, uint32_t size) {
}

void XCAMERA_recvpic(void) {
}

message_t* XCAMERA_receive(message_t* msg) {
	
	uint8_t* data = XPACKET_getData(msg);
	uint8_t cmd = data[0];
	
	switch (cmd) {
		
	case XCAMERA_START:
		
		if (C328R_start(data[1], data[2]) == SUCCESS) {
			LEDS4_on(LEDS4_YELLOW);
		}
		
		break;
		
	case XCAMERA_SNAP:
		
		
		
		break;
	}
	
	return msg;
}